# ---------------------------------------------------------------------- #
# Copyright (c) 2024-2025 [XD-AMCC TEAM]
# [XD-AMCC] is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#          http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES
# OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
# TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# ---------------------------------------------------------------------- #



cmake_minimum_required(VERSION 3.25)
project(AMCC
        VERSION 1.0.0
        DESCRIPTION "Another-Micro-C Compiler"
        LANGUAGES C)

# The definition of macros
# AMCC_VERSION_MAJOR, AMCC_VERSION_MINOR, AMCC_VERSION_PATCH
# are based on "project(...VERSION ...)"
#

# set C std version
set(CMAKE_C_STANDARD 11)

# use gcc as the compiler
set(CMAKE_C_COMPILER gcc)


# set the default build type
#
if ( NOT CMAKE_BUILD_TYPE )
    set(CMAKE_BUILD_TYPE  "Release"  CACHE STRING  "Choose the build type" FORCE)
endif ()

# output dir of executable files
set(MY_EXE_PATH ${PROJECT_SOURCE_DIR}/bin)
set(MY_DLL_PATH ${PROJECT_SOURCE_DIR}/bin)
set(MY_LIB_PATH ${PROJECT_SOURCE_DIR}/bin)

set(RUNTIME_OUTPUT_DIRECTORY   ${MY_EXE_PATH})
set(LIBRARY_OUTPUT_DIRECTORY   ${MY_DLL_PATH})
set(ARCHIVE_OUTPUT_DIRECTORY   ${MY_LIB_PATH})
set(CMAKE_INSTALL_PREFIX       ${PROJECT_SOURCE_DIR}/bin)

configure_file(
    amcc-src/amcc_config.h.in
    ${PROJECT_SOURCE_DIR}/amcc-src/libamcc/include/amcc_config.h
)


add_subdirectory(amcc-src build/amcc)

#add_subdirectory(test  build/test)
